package br.com.softwareevaluation.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConexaoUtil {
	private static ConexaoUtil instance;

	public synchronized static ConexaoUtil getInstance() {
		if (instance == null) {
			instance = new ConexaoUtil();
		}

		return instance;
	}
	
	public static Connection createConnection() {
		return createConnection(true);
	}
	
	public static Connection createConnection(boolean autoCommit) {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/softwareevaluation", "root", "Ca589142");
			connection.setAutoCommit(autoCommit);
			
			return connection;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			return null;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
	}
}